@page "~/manager/pages"
@model PageListViewModel
@inject ManagerLocalizer Localizer
@{
    ViewBag.Title = Localizer.Page["Pages"];
    ViewBag.MenuItem = "Pages";
}
@section script
{
    <script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.MainScriptUrl)"></script>
    <script src="@Url.Content(Piranha.Manager.Editor.EditorScripts.EditorScriptUrl)"></script>
    <script src="~/manager/assets/js/piranha.contentedit.min.js"></script>
    <script src="~/manager/assets/js/piranha.pagelist.min.js"></script>
    <script src="~/manager/assets/js/piranha.siteedit.min.js"></script>

    <script type="text/javascript">
        piranha.pagelist.load();
    </script>
}
@section partials
{
    @foreach (var action in Piranha.Manager.Actions.Toolbars.PageList)
    {
        if (!string.IsNullOrWhiteSpace(action.PartialView))
        {
            <partial name="@action.PartialView" />
        }
    }
}

<div id="pagelist">
    <div class="top">
        <nav aria-label="breadcrumb">
            <ol class="breadcrumb">
                <li class="breadcrumb-item">@Localizer.Menu["Content"]</li>
                <li class="breadcrumb-item active" aria-current="page">@Localizer.Menu["Pages"]</li>
            </ol>
        </nav>

        <div class="container-fluid">
            <div class="top-nav">
                @foreach (var action in Piranha.Manager.Actions.Toolbars.PageList)
                {
                    <partial name="@action.ActionView" />
                }
            </div>
        </div>
    </div>

    <div class="container-fluid app" :class="{ ready: !loading }">
        <div class="row">
            <div class="col">
                <div class="sitemap">
                    <ol>
                        <li v-for="site in sites">
                            <div class="sitemap-item" v-bind:key="site.id">
                                <div class="handle"><i class="fas fa-globe"></i></div>
                                <div class="link">
                                    <a v-if="piranha.permissions.sites.edit" v-on:click.prevent="piranha.siteedit.open(site.id, load)" href="#">{{ site.title }} <small style="display:none">(<code>{{ site.slug }}</code>)</small></a>
                                    <span v-else class="title">{{ site.title }} <small style="display:none">(<code>{{ site.slug }}</code>)</small></span>
                                </div>
                                <div>
                                    <div v-if="piranha.permissions.pages.add" class="btn-group" role="group">
                                        <button id="pageGroup" type="button" class="btn btn-sm btn-primary btn-labeled dropdown-toggle" data-toggle="dropdown" aria-haspopup="true" aria-expanded="false">
                                            <i class="fas fa-plus"></i>
                                            @Localizer.Page["Add page"]
                                        </button>
                                        <div class="dropdown-menu dropdown-menu-right" aria-labelledby="pageGroup">
                                            <a class="dropdown-item" :href="piranha.baseUrl + type.addUrl + site.id + '/' + type.id" v-for="type in pageTypes">{{ type.title }}</a>
                                        </div>
                                    </div>
                                </div>
                            </div>
                            <div class="sitemap sitemap-container dd" data-id="{ site.id }">
                                <ol class="dd-list">
                                    <sitemap-item v-for="item in site.pages" v-bind:key="item.id" v-bind:item="item"></sitemap-item>
                                </ol>
                            </div>
                        </li>
                    </ol>
                </div>
            </div>
        </div>
    </div>
    <partial name="Partial/_PageAddModal" />
</div>

<partial name="~/Areas/Manager/Shared/Partial/_SiteModal.cshtml" />
